<?php
$myDir = dirname(__FILE__) . "/";
require_once($myDir."../autoload.php");
if ( $argc == 1 || $argv[1] == "--help" ) {
  die( "\n\tUsage: php ".$argv[0]." [CONTROLLER_NAME] [PATH_TO_PROJECT]\n\n");  
}

$className = $argv[1];
$path      = $argv[2];

require_once($path . "user_autoload.php");
$contrConfig = Conf::get('controllerConfig');
if (!array_key_exists($className, $contrConfig)) die("Controller ". $className . " doesn't exist\n");


//delete controlelr file:
unlink($path. "controllers/".$className.".php");

//update controller config:
$conf = WebUtils::removeControllerFromConfig($className);
WebUtils::removeClassFromGenAutoload($className, $path);
file_put_contents(Conf::get('MY_HOME'). "config/web/controllers_config.php", $conf);
